import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:health_manager/common/routers/hm_router/hm_router.dart';
import 'package:health_manager/pages/tabbar/view.dart';

import 'common/routers/index.dart';

Future<void> main() async {
  await _initEnv();

  runApp(const MyApp());
}

Future<void> _initEnv() async {
  WidgetsFlutterBinding.ensureInitialized();

  HMRoutes.loadRoutes([RoutePages()]);
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return ScreenUtilInit(
      designSize: const Size(375, 812),
      child: MaterialApp.router(
        routerConfig: HMRoutes.routerConfig(
          initialLocation: RouteNames.home,
          tabbarRouterPaths: [
            RouteNames.home,
            RouteNames.service,
            RouteNames.device,
            RouteNames.shop,
            RouteNames.mine,
          ],
          pageBuilder: (context, state, navigationShell) {
            return MaterialPage(
              child: TabbarPage(navigationShell: navigationShell),
            );
          },
        ),
      ),
    );
  }
}
